export default class RequestError {
  constructor(status, statusText, errors) {
    this.name = 'RequestError'
    this.status = status
    this.statusText = statusText || 'Request Error'
    this.errors = errors
  }

  formatErrorMessage() {
    let errorMsg = `${this.status} ${this.statusText}`

    if (this.errors) {
      errorMsg = typeof this.errors === 'string'
        ? this.errors
        : this.errors.join('\n')
    }

    return errorMsg
  }
}
